#include "font_manager.h"

namespace jlib {


Font *FontManager::get (const std::string &path, FileDomain domain) noexcept {
  auto helper = getHelper();
  auto name = helper->getAbsolutePath(path.c_str(), domain);
  auto &ptr = this->_cache[name];
  if (ptr)
    return ptr;
  auto font = Object::create<Font>(path, domain);
  if (!font)
    return nullptr;
  return ptr = font;
}


void FontManager::clear () noexcept {
  this->_cache.clear();
}


} // namespace jlib
